import React, {useContext, useEffect, useState} from 'react';
import {
    ActivityIndicator,
    Alert,
    Dimensions,
    ImageBackground,
    RefreshControl,
    ScrollView,
    TouchableOpacity,
    View
} from 'react-native';
import {Icon, ListItem, Text} from 'react-native-elements';
import LocaleContext from '../libs/locale';
import WalletContext from '../libs/wallet';
import AsyncStorage from '@react-native-async-storage/async-storage';
import otherTokenLogo from '../assets/aboutlogo.png';

import {constansts} from "./../libs/constansts";
import {useFocusEffect} from "@react-navigation/native";
import {getTransferCount, getTxInfo, getTxs} from "../libs/nodes";
import {formartMoney, sleep, timeFormat} from "../libs/helpers";
import {hex2Bytes, hex2Bytes_Random, keyPairFromSeed} from "../libs/keyPair";
import {convertKeyPair} from "../libs/ed2curve";
import {TouchableHighlight} from "react-native-gesture-handler";
import {deAES, getGroupList} from "../libs/chatGroup";


const {width,height,scale} = Dimensions.get("window");
let showAddStatus = false;
let infoDic:any = {};
let Q_ChatListNow:any = [];
const ChatGroupMy = ({navigation,route}:any) =>{
    const locale:any = useContext(LocaleContext);
    const wallet: any = useContext(WalletContext);
    const [ChatGroupList,setChatGroupList]:any = useState([]);
    //显示加号里面的内容
    const [showAdd,setShowAdd] = useState(false);
    //进度条
    const [showWaiting,setShowWaiting] = useState(false)
    const [progressLength,setProgressLength] = useState("0")
    const [TipInfo,setTipInfo] = useState("")


    //初始化获取群聊列表信息
    useFocusEffect(
        React.useCallback(()=>{
            showAddStatus = false;
            const work = async () => {
                let ChatGroupList = await AsyncStorage.getItem("myChatGroupList") || "[]";
                // console.log("主页数据："+SaveList)
                var resList: any = JSON.parse(ChatGroupList) || [];
                console.log(ChatGroupList)
                Q_ChatListNow = resList;
                //获取所有消息放入内存
                for (let i = 0; i < Q_ChatListNow.length; i++) {
                    let addr = Q_ChatListNow[i].addressOut;
                    let ChatGroupInfo = await AsyncStorage.getItem("Q_Chat_" + addr) || "[]";
                    infoDic[addr] = JSON.parse(ChatGroupInfo) || [];
                }

                sortList(Q_ChatListNow);
                setChatGroupList(Q_ChatListNow);
            }
            work();
        },[])
    )
    //定时器获取群聊消息
    useFocusEffect(
        React.useCallback(() => {
            let unDoIt = false;
            var t:any;
            const interval_GetInfo = async () => {
                await saveNetMsg_All_Q_Chat();
                if(unDoIt)
                {
                    return ;
                }
                t = setTimeout(interval_GetInfo,10*1000);
            }
            interval_GetInfo();
            return ()=>{
                clearTimeout(t);
                unDoIt = true;
            }
        }, []))
    //初始化一下标题和加号按钮
    useEffect(() => {
        setTitle("群聊");
        navigation.setOptions({
            headerRight: () => (
                <TouchableOpacity style={{
                    width: 35,
                    height: 35,
                    marginRight: 20,
                    alignItems: "center",
                    justifyContent: "center"
                }}
                                  onPress={ () => {
                                      showAddStatus = !showAddStatus;
                                      console.log(showAddStatus)
                                      setShowAdd(showAddStatus);
                                  }}
                >
                    <Icon type='feather' name="plus-circle" color={'#000'} size={width/360*27} style={{}} />
                </TouchableOpacity>


            ),
        });
    },[])

    const setTitle = (title:string) => {
        navigation.setOptions({title: title})
    }

    //获取历史交易
    const getHistory = async (address:string) => {
        var info: any = [];
        //获取最多12000笔交易的信息
        let LastTime: number;
        try {
            LastTime = parseInt(await AsyncStorage.getItem("LastGetTime_"+address) as string) - 1;
            if(new Date().getTime() - LastTime > constansts.chatSearchMaxTime)
            {
                LastTime = new Date().getTime() - constansts.chatSearchMaxTime;
            }
        }catch (e) {
            LastTime = new Date().getTime() - constansts.chatSearchMaxTime;
        }

        for (let i = 0; i < Math.floor(constansts.chatSearchMaxLength/12); i++) {
            let res = [];
            res = await getTxs(address, i);
            info.splice(12 * (i + 1) - 1, 0, ...res);
            let nowGetTime = 0;
            try {
                nowGetTime = parseInt(res[res.length - 1].timestamp);
            }catch (e) {
            }
            if (info.length !== (i + 1) * 12 || nowGetTime <= LastTime) {
                break;
            }
        }
        if(info.length > 0)
            await AsyncStorage.setItem("LastGetTime_"+address,info[0].timestamp.toString());
        return info;
    }
    //将得到的消息数据进行解析放入数组等待比较
    const solveTran = async (info:any,Q_Key:string) => {

        //信息解密
        const decryptedInformation = async (item:any,Key:string) =>{
            await sleep(0)
            let timetemp_decry = new Date().getTime()
            try {
                let nacl = require("tweetnacl");
                //将字符串转成字节数组
                let decodeUTF8 = function (s: string) {
                    var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
                    for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
                    return b;
                };
                //将字节数组转成字符串
                let encodeUTF8 = function (arr: any) {
                    var i, s = [];
                    for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
                    return decodeURIComponent(escape(s.join('')));
                };
                //设置随机nonce值
                nacl.setPRNG((x: any, n: any) => {
                    x = hex2Bytes_Random(n);
                })
                // 随机nonce值
                let nonceRandom = nacl.randomBytes(24);
                let DHKeyMy:any = convertKeyPair(keyPairFromSeed(wallet.seed));

                //获取他的公钥
                let data = JSON.parse(item.remarks);
                var decryptedMessage = nacl.secretbox.open(hex2Bytes(data.msg), nonceRandom,hex2Bytes(Key));
                let res = encodeUTF8(decryptedMessage)
                return res;
            }catch (e) {
                return false;
            }
        }

        var ChatListTemp:any = [];
        for (let i = 0; i < info.length; i++) {
            await sleep(0);
            try {

                let remarks = JSON.parse(info[i].remarks);
                if (remarks.type !== "Gchat") {
                    continue;
                }
                let remarksMsgStr = await decryptedInformation(info[i],Q_Key);
                if(!remarksMsgStr)
                {
                    continue;
                }
                info[i].remarks = JSON.stringify({height:info[i].height,receiver:info[i].addressOut,hash:info[i].hash,type:"Gchat",msg:remarksMsgStr,sender:info[i].addressIn});
            } catch (e) {

                continue;
            }

            let remarks = JSON.parse(info[i].remarks);

            ChatListTemp.push({height:info[i].height,receiver:info[i].addressOut,hash:info[i].hash,sender: info[i].addressIn, msg: remarks.msg, timeStamp: info[i].timestamp});
        }

        return ChatListTemp;
    }
    //将得到的数组进行比较，然后写入数据库
    const saveMsg = async (ChatListTemp: any,address:string) => {
        //添加数据量的限制
        let maxInfoLength = constansts.Q_ChatInfoMaxLength;

        //获取数据库中这个人的聊天信息
        let ChatGroupList = await AsyncStorage.getItem("Q_Chat_"+address) || "[]";
        let Q_ChatNow = JSON.parse(ChatGroupList) || [];

        //将数据添加进去，如果发现时间戳一样并且，发送人一样的数据将发送中标识去除
        for (let i = 0; i < ChatListTemp.length; i++) {
            //本来就没有消息直接放进去
            if (Q_ChatNow.length === 0) {
                Q_ChatNow.push(ChatListTemp[i]);
                continue;
            }
            //有消息遍历一下，如果有相同的就修改一下状态，没有相同的就直接放进去
            for (let ii = 0; ii < Q_ChatNow.length; ii++) {
                //如果里面已经有这条消息的话，就可以直接修改状态
                if (ChatListTemp[i].sender === Q_ChatNow[ii].sender && ChatListTemp[i].timeStamp === Q_ChatNow[ii].timeStamp) {
                    //修改数据状态
                    Q_ChatNow[ii].showFalse = false;
                    Q_ChatNow[ii].showTraning = false;
                    Q_ChatNow[ii].height = ChatListTemp[i].height;
                    break;
                }
                if(ii===0 && ChatListTemp[i].timeStamp < Q_ChatNow[ii].timeStamp)
                {
                    if(Q_ChatNow.length >= maxInfoLength)
                    {
                        break;
                    }
                    Q_ChatNow.splice(0,0,ChatListTemp[i]);
                    console.log(JSON.stringify(Q_ChatNow))
                    break
                }
                //新的消息
                if(ii < (Q_ChatNow.length - 1) && ChatListTemp[i].timeStamp < Q_ChatNow[ii+1].timeStamp)
                {
                    let k=ii+1;
                    if(Q_ChatNow.length >= maxInfoLength)
                    {
                        Q_ChatNow.shift();
                        k--;
                    }
                    Q_ChatNow.splice(k,0,ChatListTemp[i]);
                    break;
                }
                //到了最后一个也没有满足条件的消息，就直接添加进去
                if(ii === (Q_ChatNow.length - 1))
                {
                    if(Q_ChatNow.length >= maxInfoLength)
                    {
                        Q_ChatNow.shift();
                    }
                    Q_ChatNow.push(ChatListTemp[i]);
                    break;
                }
            }
        }

        //最后将那些还没有去除发送标识的人，比较一下发送时间，时间过了2分钟就查询后判断一下将它设置为丢失或者成功
        for (let i = 0; i < Q_ChatNow.length; i++) {
            let data = Q_ChatNow[i];
            if (data.showTraning && ((new Date().getTime()) - data.timeStamp) > (2 * 60 * 1000) && data.display !== false) {
                let HashInfo = await getTxInfo(data.hash);
                if (data.falseTime <= 0 && (HashInfo == false || HashInfo.height == 0)) {
                    data.showFalse = true;
                    data.showTraning = false
                    data.height = -2;
                }
                data.falseTime -= 1;
                if(HashInfo.height > 0)
                {
                    data.showFalse = false;
                    data.showTraning = false;
                    data.height = HashInfo.height;
                }
            }
            Q_ChatNow[i] = data;
        }
        infoDic[address] = Q_ChatNow;
        await AsyncStorage.setItem("Q_Chat_"+address, JSON.stringify(Q_ChatNow));

        return Q_ChatNow;
    }
    //检查是否需要去网络上重新获取数据
    const checkNeedUpdate = async (address:string) => {
        let beforeTransferCountStr: string | null = "0";
        try {
            beforeTransferCountStr = await AsyncStorage.getItem("Q_tranCount_"+address);
        }catch (e) {
            beforeTransferCountStr = "0";
        }
        console.log(`beforeTransferCountStr:${beforeTransferCountStr}`)
        if(beforeTransferCountStr == null || beforeTransferCountStr == "0")
        {
            let newTransferCount = await getTransferCount(address);

            await AsyncStorage.setItem("Q_tranCount_"+address,newTransferCount.count.toString());
            return true;

        }
        let beforeTransferCount = parseInt(beforeTransferCountStr);

        let newTransferCount = await getTransferCount(address);

        if(newTransferCount.count > beforeTransferCount)
        {
            await AsyncStorage.setItem("Q_tranCount_"+address,newTransferCount.count.toString());
            return true;
        }
        return false;
    }
    //检查未完成的交易
    const checkTransferring = async (address:string) => {
        //获取数据库中这个人的聊天信息
        let ChatGroupList = await AsyncStorage.getItem("Q_Chat_"+address) || "[]";
        let Q_ChatNow = JSON.parse(ChatGroupList) || [];

        for (let i = 0; i < Q_ChatNow.length; i++) {
            let data = Q_ChatNow[i];
            if (data.showTraning && ((new Date().getTime()) - data.timeStamp) > (2 * 60 * 1000) && data.display !== false) {
                let HashInfo = await getTxInfo(data.hash);
                if (data.falseTime <= 0 && (HashInfo == false || HashInfo.height == 0)) {
                    data.showFalse = true;
                    data.showTraning = false;
                    data.height = -2;
                }
                data.falseTime -= 1;
                if(HashInfo.height > 0)
                {
                    data.showFalse = false;
                    data.showTraning = false;
                    data.height = HashInfo.height;
                }
                Q_ChatNow[i] = data;
            }
        }
        infoDic[address] = Q_ChatNow;
        await AsyncStorage.setItem("Q_Chat_"+address, JSON.stringify(Q_ChatNow));
    }
    //获取网络数据，来检查交易是否成功和新增的聊天数据
    const saveNetMsg = async (address: string,key:string) => {
        //如果不需要更新数据，那就不懂
        if (!await checkNeedUpdate(address)) {
            await checkTransferring(address);
            return;
            //后面补上交易丢失问题
        }
        //需要更新数据，先去拉去数据
        //获取最新交易
        var info = await getHistory(address);

        //将得到的消息数据进行解析放入数组等待比较
        var ChatListTemp = await solveTran(info,key);

        //将得到的数组进行比较，然后写入数据库
        let res = await saveMsg(ChatListTemp,address);

        return res;

    }
    //获取所有群聊的网络数据
    const saveNetMsg_All_Q_Chat = async () => {
        for (let i = 0; i < Q_ChatListNow.length; i++) {
            let address = Q_ChatListNow[i].addressOut;
            let key = Q_ChatListNow[i].Key ;
            await saveNetMsg(address , key);
        }
        sortList(Q_ChatListNow);
    }
    //获取所有群聊的网络数据并且设置进度条
    const saveNetMsg_All_Q_Chat_Waiting = async () => {
        for (let i = 0; i < Q_ChatListNow.length; i++) {
            await saveNetMsg(Q_ChatListNow[i].addressOut, Q_ChatListNow[i].Key);
            setProgressLength((0.7+(i+1)/Q_ChatListNow.length*0.3).toString())
        }
        sortList(Q_ChatListNow);
    }
    //排序这个列表
    const sortList = (List:any) => {
        const getLastTime = (address:string) => {
            try {
                return infoDic[address][infoDic[address].length - 1].timeStamp;
            }catch (e) {
                return 3744434681000;
            }
        }
        function bubbleSort(arr:any) {//冒泡排序
            let len = arr.length;
            for(let i = 0; i < len - 1; i++) {
                for(let j = 0; j < len - 1 - i; j++) {
                    try {
                        let j_timeStamp = getLastTime(arr[j].addressOut)
                        let j_NextTimeStamp = getLastTime(arr[j+1].addressOut)
                        if (j_timeStamp < j_NextTimeStamp) {       // 相邻元素两两对比
                            let temp = arr[j + 1];       // 元素交换
                            arr[j + 1] = arr[j];
                            arr[j] = temp;
                        }
                    }catch (e) {
                    }
                }
            }
            return arr;
        }
        let resultList = bubbleSort(List);
        try{
            setChatGroupList([...resultList]);
        }catch (e) {
            console.log("渲染失败")
        }
        return resultList;
        AsyncStorage.setItem("myChatGroupList",JSON.stringify(resultList))
    }
    //获取这个群聊最后一句话
    const getQChatLast =  (address: string) => {
        try {
            return infoDic[address][infoDic[address].length - 1].msg;
        }catch (e) {
            return "";
        }
    }
    //获取这个群聊最后一句话的时间
    const getQChatLastTime = (address: string) => {
        try {
            return timeFormat(infoDic[address][infoDic[address].length - 1].timeStamp).slice(5,16);
        }catch (e) {
            return ""
        }
    }
    //获取我的加入过的群聊
    const getMyChatGroupList = async () => {
        try {
            setTipInfo("正在获取网络数据")
            setShowWaiting(true);
            await sleep(0)
            let myChatGroupList = [];
            let myChatGroupListStr = await AsyncStorage.getItem("myChatGroupList");
            if (myChatGroupListStr) {
                myChatGroupList = JSON.parse(myChatGroupListStr);
            }

            let res = await getGroupList(wallet.address);
            setTipInfo("正在解析网络数据")
            for (let i = 0; i < res.groups.length; i++) {
                console.log(i)
                let data:any = {};
                try{
                    data = {
                        addressOut: res.groups[i].addressout,
                        Creator: res.groups[i].creator,
                        Key: deAES(wallet.seed, res.groups[i].key),
                        desc: res.groups[i].desc,
                        Voucher: res.groups[i].voucher,
                        type: "Gchat"
                    };
                }catch (e) {
                    continue;
                }

                let res_Index = myChatGroupList.findIndex((item: any) => item.addressOut === data.addressOut);
                if (res_Index > -1) {
                    myChatGroupList[res_Index].show == false?(myChatGroupList[res_Index].show =true):null;
                    let pl = ((i + 1) *0.7 / res.groups.length).toString();
                    setProgressLength(pl);
                    continue;
                }
                myChatGroupList.push(data);

                let pl = ((i + 1) * 0.7 / res.groups.length).toString();
                await sleep(5000)
                setProgressLength(pl);
            }
            Q_ChatListNow = sortList(myChatGroupList);
            await AsyncStorage.setItem("myChatGroupList", JSON.stringify(myChatGroupList));


            await saveNetMsg_All_Q_Chat_Waiting()

            setShowWaiting(false);
            setProgressLength("0");
        }catch (e) {
            setShowWaiting(false);
            setProgressLength("0");
        }
    }

    return (
        <View>
            {
                showWaiting?
                    <View style={{width:width,height:height,backgroundColor:"#F5F5F5"}}>
                        <ActivityIndicator
                            animating={true}
                            color={'lightblue'}
                            size={50}
                            style={{width:width,backgroundColor:"#FFFAFA69",marginTop:0.3*height}}
                        />
                        <Text style={{alignSelf:"center",marginTop:20}}>{formartMoney((parseFloat(progressLength)*100).toString(),2)}% {TipInfo}</Text>
                        <View style={{backgroundColor:"#DCDCDC",width:width*0.8,height:20,borderRadius:10,marginTop:25,alignSelf:"center"}}/>
                        <View style={{backgroundColor:"#69BDF4",width:width*0.8*parseFloat(progressLength)>20?width*0.8*parseFloat(progressLength):20,height:20,borderRadius:10,marginTop:-20,alignSelf:"flex-start",marginLeft:width*0.1}}/>
                    </View>
                    :null
            }
            {
                showAdd?
                    <View style={{width:150,height:51*4,backgroundColor:"#545454",position:"absolute",right:20,top:0,zIndex:55,borderRadius:5}}>
                        <TouchableHighlight
                            underlayColor={"transparent"}
                            onPress={()=>{
                            showAddStatus = false;
                            setShowAdd(false)
                            navigation.navigate("ChatGroupCreate")}}>
                            <View style={{flexDirection:"row",alignItems:"center",height:51,paddingTop:5,paddingLeft:15}}>
                                <Icon type='feather' name="plus-circle" color={'#fff'} size={width/360*27} style={{marginRight:15}} />
                                <Text style={{fontSize:width/360*16,color:"#fff",fontWeight:"bold",letterSpacing:1}}>
                                    创建群聊
                                </Text>
                            </View>
                        </TouchableHighlight>
                        <TouchableHighlight
                            underlayColor={"transparent"}
                            onPress={()=>{
                            showAddStatus = false;
                            setShowAdd(false)
                            navigation.navigate("ChatGroupJoin")}}>
                            <View style={{flexDirection:"row",alignItems:"center",height:51,paddingTop:5,paddingLeft:15}}>
                                <Icon type='feather' name="user-plus" color={'#fff'} size={width/360*27} style={{marginRight:15}} />
                                <Text style={{fontSize:width/360*16,color:"#fff",fontWeight:"bold",letterSpacing:1}}>
                                    加入群聊
                                </Text>
                            </View>
                        </TouchableHighlight>
                        <TouchableHighlight
                            underlayColor={"transparent"}
                            onPress={()=>{
                            showAddStatus = false;
                            setShowAdd(false)
                            navigation.navigate("ChatGroupQRscan")}}>
                            <View style={{flexDirection:"row",alignItems:"center",height:51,paddingTop:5,paddingLeft:15}}>
                                <Icon type='feather' name="maximize" color={'#fff'} size={width/360*27} style={{marginRight:15}} />
                                <Text style={{fontSize:width/360*16,color:"#fff",fontWeight:"bold",letterSpacing:1}}>
                                    扫一扫
                                </Text>
                            </View>
                        </TouchableHighlight>
                        <TouchableHighlight
                            underlayColor={"transparent"}
                            onPress={()=>{
                            showAddStatus = false;
                            setShowAdd(false)
                            getMyChatGroupList()}}>
                            <View style={{flexDirection:"row",alignItems:"center",height:51,paddingTop:5,paddingLeft:15}}>
                                <Icon type='feather' name="crosshair" color={'#fff'} size={width/360*27} style={{marginRight:15}} />
                                <Text style={{fontSize:width/360*16,color:"#fff",fontWeight:"bold",letterSpacing:1}}>
                                    我的群聊
                                </Text>
                            </View>
                        </TouchableHighlight>
                    </View>
                    :null
            }
            <ScrollView
                style={{height:height*0.9}}
                refreshControl={
                    <RefreshControl refreshing={false} onRefresh={() => {saveNetMsg_All_Q_Chat()}} collapsable={true}/>
                }
                onTouchStart={()=>{setTimeout(()=>{
                    showAddStatus = false;
                    setShowAdd(false)
                },100);}}
            >
                <View >
                    {
                        ChatGroupList.length
                            ?
                            ChatGroupList.map((tx: any,index:any) => (
                                tx.show!==false?
                                    <TouchableHighlight
                                        underlayColor="rgba(34, 26, 38, 0.1)"
                                        onPress={ async ()=>
                                        {
                                            navigation.navigate("ChatGroupView",{Q_Address:tx.addressOut,Q_Key:tx.Key,QP_Priv:tx.Voucher,Creator:tx.Creator,desc:tx.desc,selfRemark:tx.selfRemark||""})
                                        }}
                                        onLongPress={async () => {
                                            const delQChat = async () => {
                                                Q_ChatListNow[index].show = false;
                                                await AsyncStorage.setItem("myChatGroupList", JSON.stringify(Q_ChatListNow));
                                                setChatGroupList(Q_ChatListNow);
                                            }
                                            Alert.alert('', `是否删除 ${tx.desc || (tx.addressOut.slice(0,5)+"..."+tx.addressOut.slice(-5))} 的群消息`, [{
                                                text: locale?._('cancel'),
                                                onPress: () => console.log("Cancel Pressed"),
                                                style: "cancel"
                                            }, {
                                                text: locale?._('ok'),
                                                onPress: async () => {
                                                    await delQChat();
                                                }}
                                            ]);
                                        }}
                                        key={index}>
                                        <View style={{flexDirection:"row",marginTop:5,padding:10,paddingBottom:0}}>
                                            <ImageBackground source={tx.logo?{uri:tx.logo.uri}:otherTokenLogo} style={{ width: 45, height: 45 ,marginRight:15,marginTop:5}} />
                                            <ListItem.Content style={{borderBottomColor:"#F5F5F5",borderBottomWidth:1,paddingBottom:7}}>
                                                <ListItem.Title style={{fontSize:width/360*15,marginBottom:10}} numberOfLines={1}>{tx.desc}</ListItem.Title>
                                                <ListItem.Subtitle style={{height:15,fontSize:width/360*10}} numberOfLines={1}>
                                                    <Text numberOfLines={1} style={{color:'grey'}}>
                                                        {getQChatLast(tx.addressOut)}
                                                    </Text>
                                                </ListItem.Subtitle>
                                            </ListItem.Content>
                                            <View style={{borderBottomColor:"#F5F5F5",paddingBottom:7,borderBottomWidth:1,width:width/360*80,flexDirection:"column",alignItems:"flex-end",marginRight:width/360*0}}>
                                                <View style={{flexDirection:"column",width:width/360*80,justifyContent:"flex-end",marginBottom:10}}>
                                                    <Text style={{fontSize:width/360*12,color:"grey",alignSelf:"flex-end"}}>
                                                        {getQChatLastTime(tx.addressOut)}
                                                    </Text>
                                                </View>
                                                <View style={{flexDirection:"column",width:width/360*50,justifyContent:"center"}}>
                                                    {
                                                        tx.unread?
                                                            <Text style={{marginTop:5,fontSize:width/360*12,color:"white",alignSelf:"flex-end",backgroundColor:"lightgrey",paddingLeft:12,paddingRight:12,borderRadius:12}}>
                                                                {tx.unread || ""}
                                                            </Text>
                                                            :
                                                            <Text style={{marginTop:5,fontSize:width/360*12,color:"white",alignSelf:"flex-end"}}>
                                                                {""}
                                                            </Text>
                                                    }

                                                </View>
                                            </View>
                                            {/*<Icon type='feather' name='arrow-right' color='#7259E0FF' size={24} />*/}
                                        </View>
                                    </TouchableHighlight>
                                    :null
                            ))
                            :
                            <View style={{ flex: 1, justifyContent: 'center' }}>
                                <Text style={{
                                    marginTop: '100%',
                                    fontSize: 20,
                                    textAlign: 'center',
                                    color: 'grey'
                                }}>{locale?._('noContent')}</Text>
                            </View>
                    }
                </View>
            </ScrollView>

        </View>
    );
};
export default ChatGroupMy;
